clear
set matsize 11000

********************************************************************************
* Read-in panel bloomberg data
use "./data/fomc_panel_b", clear

label var mps_2day "mps"
label var mpu10_2day "mpu"

******CREATE VARIABLES FOR TABLE 7*****
foreach v in ex_rate_regime us_integ trade_open ka_open fin_depth dollar_exp dollar_debt vuln_index int_diff_3m int_diff_3m_chg {

*Step 1: Standardize each exposure variable, i.e. subtract mean and divide by std. dev.

	sum `v' 
	gen `v'_std = (`v' - r(mean)) / r(sd)
	
*Step 2: Construct a logistic transformation of the standardized variable

	gen `v'_log =  exp(`v'_std) / (1 + exp(`v'_std))
	
*Step 3: Re-center the logistic variable in terms of distance between 25th and 75th percentiles

	sum `v'_log, detail
	gen `v'_exposure = (`v'_log - r(p25)) / (r(p75) - r(p25))
	

*Step 4: Construct interaction term with shocks

	gen `v'_mps_int = `v'_exposure * mps_2day
	
	gen `v'_mpu_int = `v'_exposure * mpu_2day

}	 

*Drop U.S.
drop if ccode==49

********************************************************************************
***Table 7: Response of term premium component of international bond yields to 
***			monetary shocks (bond substitutability interaction)
********************************************************************************

****SCALED TO -1 TO 1 CHANGE****
gen corr_full_sample_scaled = (corr_full_sample + 1) / 2

quietly: reghdfe tp10y_bc_2day_std c.mps_2day##c.corr_full_sample_scaled mpu10_2day c.mpu10_2day#c.corr_full_sample_scaled, noabsorb cluster(date ccode)
outreg2 using "tables\table7.xml",  bdec(2) excel replace

quietly: reghdfe tp10y_bc_2day_std c.mps_2day##c.corr_full_sample_scaled mpu10_2day c.mpu10_2day#c.corr_full_sample_scaled if advanced, noabsorb cluster(date ccode)
outreg2 using "tables\table7.xml",  bdec(2) excel append

quietly: reghdfe tp10y_bc_2day_std c.mps_2day##c.corr_full_sample_scaled mpu10_2day c.mpu10_2day#c.corr_full_sample_scaled if !advanced, noabsorb cluster(date ccode)
outreg2 using "tables\table7.xml",  bdec(2) excel append

********************************************************************************